/************************************************************************

								Heroes IV
					  Copyright 2000, The 3DO Company

	------------------------------------------------------------------
  						       resurrect_heroes.cpp

	$Header: /game/resurrect_heroes.cpp $

	$NoKeywords: $

 ************************************************************************/
// kill the 255+ character identifier warning.  Templates tend to exceed that easily.
#include "precompiled.h"
#pragma warning( disable: 4786 )

#include "resurrect_heroes.h"

#include "basic_dialog.h"
#include "creature_array.h"
#include "game_replace_keywords.h"
#include "hero.h"
#include "player.h"

void resurrect_heroes( t_creature_array& army, std::string const& prompt_text, t_window* window )
{
	t_hero*					hero;
	std::vector<t_hero*>	heroes;
	int						i;

	for (i = 0; i < t_creature_array::k_size; ++i)
	{
		hero = army[i].get_hero();
		if (hero == 0)
			continue;
		hero->set_wounds( 0 );
		if (!hero->is_dead())
			continue;
		hero->set_dead( false );
		hero->set_wounds( 0 );
		heroes.push_back( hero );
	}
	if (heroes.empty())
		return;
	if (army.get_owner() == 0 || army.get_owner()->is_computer() || window == 0)
		return;

	t_counted_ptr<t_basic_dialog>	dialog;
	std::string						text;

	dialog = new t_basic_dialog;
	
	text = replace_keywords( prompt_text, heroes );
	
	for (i = 0; i < heroes.size(); ++i)
		dialog->add_creature_icon( *heroes[i], heroes[i]->get_name(), heroes[i]->get_name() ); 
	dialog->set_text( text );
	dialog->add_ok_button();
	dialog->open();
	dialog->run_modal();
}
